<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>我的订单</title>

    <div th:include="includeJs::includeJs"></div>
    <div th:include="includeJs::layui_js"></div>

    <link rel="stylesheet" th:href="@{/css/account/lay-cz.css}">
    <link rel="stylesheet" th:href="@{/css/userInfo/common.css}">
    <link rel="stylesheet" th:href="@{/css/userInfo/user.css}">
    <link rel="stylesheet" th:href="@{/css/userInfo/fileupload.less.css}">

    <script type="text/javascript" th:src="@{/js/userInfo/common.js}"></script>
    <script type="text/javascript" th:src="@{/js/userInfo/user.js}"></script>
</head>
<body>
<!--最上面-->
<link th:replace="includeJs::dingding_header">
<!--第二上面-->
<div style="background-color: white;width: 100%">
    <link th:replace="includeJs::dingding_nav">
</div>
<div class="wrapper wbgcolor">
    <div class="w1200 personal">
        <link th:replace="includeJs::userInfoMenu">
        <div class="personal-main">
            <div class="personal-zqzr personal-xtxx" style="min-height: 500px;">
                <h3><i>我的订单</i></h3>
                <form  class="layui-form"  id="form" name="form" method="post" action="">
                    <div class="zqzr-list">
                        <ul class="list_content">
                            <table class="layui-hide" id="order_table"></table>
                        </ul>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<link th:replace="includeJs::userInfoJS">
</body>
<script type="text/html" id="toolDemo">
</script>
<script>
    layui.use([ 'element', 'table', 'layer', 'form' ,'laydate','upload','layedit'],function() {
        var element = layui.element;
        var layer = layui.layer;
        var table = layui.table;
        var form = layui.form;
        var laydate = layui.laydate;
        var upload = layui.upload;
        var layedit = layui.layedit;

        table.render({
            elem: '#order_table'
            ,url:'/orderList'
            ,cols: [
                [
                {field:'userName', width:100, title: '用户名'}
                ,{field:'userPhone', width:150, title: '电话'}
                ,{field:'userAddress', width:250, title: '地址'}
                ,{field:'logisticsCompany', title: '物流公司', width: '100', minWidth: 100} //minWidth：局部定义当前单元格的最小宽度，layui 2.2.1 新增
                ,{field:'orderState',width: '100', title: '货物状态',templet:function (d) {
                        if (d.orderState === [[${T(com.ddf.publics.tool.Constant).TO_BE_DELIVERED}]]) {
                            return '<button type="button" class="layui-btn layui-btn-xs">待发货</button>\n'
                        }else if(d.orderState === [[${T(com.ddf.publics.tool.Constant).SHIPPED}]]) {
                            return '<button type="button" class="layui-btn layui-btn-normal layui-btn-xs">已发货</button>\n'
                        }else if(d.orderState === [[${T(com.ddf.publics.tool.Constant).TO_BE_RECEIVED}]]){
                            return '<button type="button" class="layui-btn layui-btn-warm layui-btn-xs">待收货</button>\n'
                        }else if(d.orderState === [[${T(com.ddf.publics.tool.Constant).RECEIVED}]]){
                            return '<button type="button" class="layui-btn layui-btn-danger layui-btn-xs">已收货</button>\n'
                        }
                    }}
                ,{field:'remarks',width: '100', title: '备注'}
                ,{field:'orderState',templet:function (d) {
                        if(d.orderState == 3){
                            return "<input hidden class='orderId' value="+d.orderId+" /><button id='confirm' class=\"layui-btn layui-btn-sm layui-btn layui-btn-normal\" ><i class=\"layui-icon layui-icon-edit\"></i>确认收货</button>\n"
                        }else {
                            return "<button disabled class=\"layui-btn layui-btn-sm layui-btn-disabled\" ><i class=\"layui-icon layui-icon-edit\"></i>确认收货</button>\n"
                        }
                    },fixed: 'right',width: '130',title: '操作'}
            ]
            ]
            ,page: true
            ,page: {limit:10,page:1,limits:[10,30,50,100],layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']}
        });
        $(".list_content").on('click','#confirm',function () {
            $.post('/ReceivingGoods',{id:$(this).prevAll(".orderId").val()},function (d) {
                if(d == "yes"){
                    layer.msg("收货成功",{icon:1});
                }else if(d == "error"){
                    layer.msg("错误",{icon:2});
                }
            },'text')
        })
    });
</script>
</html>